package confidence.helpers;



import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;


/**
 * 
 * 
 * @author Bostjan
 */
public class PreprocessQM  {


	public static int currentAfterBreakNo=0;
	private Assembler<SnapshotUbi> assUbi = new Assembler<SnapshotUbi> (new FactoryUbi ());

	
	public PreprocessQM () 
	{
		
	}
	
	
	public Snapshot getSnapshot(String tag)
	{
		String input = (String) tag.toString();
		Snapshot snap = null;
		
		if (input != null)
		{
			String tagClass = null;
		    if (input.compareTo ("") == 0) {
	            currentAfterBreakNo++;
	            snap = null;
		    }
            else {
               
                String [] ping = input.split ("\\,");
          
                tagClass = ping[7];
               
                Date date=null;
                SimpleDateFormat sdf;
                try {
                    sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss:SSS", Locale.ITALY);
                    date = sdf.parse(ping[3]);                           

                } catch (ParseException e) {
                    e.printStackTrace();
                }
                
                snap = assUbi.addTag (new Tag (date,Double.parseDouble (ping [4]), Double.parseDouble (ping [5]), Double.parseDouble (ping [6])), ping [1], tagClass);
                
            }
		                
            if(snap != null)
            {
                return snap;
	        }
            
		
	}
	
	return null;
	


	
	}
}
